/**
 * # # THIS FILE IS PART OF micro-plateform PROJECT
 * # #
 * # .java -
 * #
 * # THIS PROGRAM IS OPENSOURCE SOFTWARE, IS LICENSED UNDER BSD
 * # YOU SHOULD HAVE RECEIVED A COPY OF WTFPL LICENSE
 * #
 * # Copyright (c) 2018 Ting Fan
 */
package com.cloudkinto.common.utils.regex;

import java.util.regex.Pattern;

/**
 * @program     : micro-plateform
 * @description : 
 * @author      : Ting Fan
 * @company     : 苏州
 * @create      : 2019-10-25 01:01
 **/
public class IpRegexUtils {


    public static boolean ipRegex(String ipStr) {
        boolean resultBoolean = true;
        //正则检验ip地址
        String ipRegex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)$";

        if (!Pattern.matches(ipRegex, ipStr)) {
            resultBoolean = false;
        }
        return resultBoolean;
    }
}
